#ifndef SETTING_SUB_CONTROLL_ITEM_H
#define SETTING_SUB_CONTROLL_ITEM_H

#include <fstream>
#include <string>
#include <vector>
#include <string>
#include <dirent.h>
#include <string.h>

#include <subControllItem.h>
#include <broadcast.h>
#include <viewConf.h>

namespace View {

  class BackgroundSelector;

  class ImageForBackgroundSelector
  {
    GooCanvasItem *bgImage;
    BackgroundSelector *father;
    int rowX;
    int lineY;
    std::string imageName;
  public:
    ImageForBackgroundSelector(GooCanvasItem *root,std::string path,
			       double x,double y,int newRowX,int newLineY,
			       BackgroundSelector *newFather,std::string newImageName);
    ~ImageForBackgroundSelector();
    BackgroundSelector *GetSelector(){return father;}
    int GetRowX(){return rowX;}
    int GetLineY(){return lineY;}
    const std::string *GetImageName(){return &imageName;}
  };

  class BackgroundSelector
  {
    GooCanvasItem *scrollWindowGoo;
    GtkWidget *scrollWindow;
    GooCanvasItem *canvas;
    GooCanvasItem *foreground;
    double foregroundX;
    double foregroundY;
    std::vector<ImageForBackgroundSelector*> images;
    bool foregroundStillMoving;
  public:
    BackgroundSelector(GooCanvasItem *parent);
    ~BackgroundSelector();
    bool MoveForeGroundTo(int rowX,int lineY);
    friend void ForegroundAnimationFinished(GooCanvasItemModel *item,
					    gboolean            stopped,
					    gpointer            user_data);
    friend gboolean on_image_press_event_cb (GooCanvasItem *item,
					     GooCanvasItem *target_item,
					     GdkEventButton *event,
					     gpointer user_data);
  };

  class LanguageSelector;

  class ImageForLanguageSelector
  {
    GooCanvasItem *bgImage;
    LanguageSelector *father;
    int rowX;
    Controller::Language currentLang;
  public:
    ImageForLanguageSelector(GooCanvasItem *root,std::string path,
			     double x,double y,int newRowX,
			     LanguageSelector *newFather,Controller::Language newLang);
    ~ImageForLanguageSelector();
    LanguageSelector *GetSelector(){return father;}
    int GetRowX(){return rowX;}
    Controller::Language GetCurrentLang(){return currentLang;}
  };

  class LanguageSelector
  {
    double baseX;
    double baseY;
    double foregroundX;
    GooCanvasItem *foreground;
  public:
    LanguageSelector(GooCanvasItem *parent);
    ~LanguageSelector();
    bool MoveForeGroundTo(int rowX);
  };
  
  class SettingSubControllItem : public SubControllItem
  {
    //    GooCanvasItem *root;
    BackgroundSelector *bacgrounds;
    LanguageSelector *languages;
    
    GooCanvasItem *backgroundMessage;
    GooCanvasItem *languagesMessage;
  public:
    SettingSubControllItem(GooCanvasItem *parent);
    ~SettingSubControllItem();
    
    virtual int OnReceive(Controller::Broadcast *broadcast);
    bool SendAllAddress(){return true;}
    bool CheckInputData(){return true;}
  };

}

#endif
